﻿import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.lang.Thread;

public class MainMid extends MIDlet
{
	MainPit myScreen;
	boolean first=true;
	public MainMid()
	{
		myScreen = new MainPit(this);
	}
	
	protected void destroyApp(boolean unconditional) 
	{
    }
    
    protected void pauseApp() 
    { 
    }
    
    
	protected void startApp()//J2ME程序的执行线程，自动执行响应按键。
	{
		Display.getDisplay(this).setCurrent(myScreen);//myScreen获得当前屏幕的显示权
		if(first)//限定执行线程只执行一次
		{
			try
			{
				Thread myThread = new Thread(myScreen);//开启一个线程用来实现游戏的逻辑与绘制
				myThread.start();//打开线程
			}
			catch(Error e)
			{
				destroyApp(false);
				notifyDestroyed();
			}
			first = false;
		}
	}
	
	//游戏结束
	public void exit()//关闭执行线程，整体程序退出
	{
		destroyApp(true);
		notifyDestroyed();
	}
	
}		








